package com.enjoyor.soa.traffic.rest.efoms.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.enjoyor.soa.traffic.api.dto.efoms.CheckDeviceInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.CheckRecodeInfoDto;
import com.enjoyor.soa.traffic.api.service.dubbo.efoms.IDubboCheckDeviceInfoService;
import com.enjoyor.soa.traffic.frame.annotation.Auth;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.ICheckDeviceInfoConsumeService;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;

@Auth
@RestController
@RequestMapping({ "/checkDevice" })
@Api("CheckRecordInfoController")
@CrossOrigin
public class CheckDeviceInfoController {

	@Autowired 
	private ICheckDeviceInfoConsumeService checkDeviceInfoConsumeService;
	
	/**
     * 获取设备巡检对象信息；
     * @param CheckRecordInfoId
     * @return
     */
	@GetMapping(value = { "/getCheckDeviceInfo" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=CheckDeviceInfoDto.class, code = 0, message = "")
    @ApiOperation("获取巡检设备对象")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "DevId", value = "设备编号", paramType = "query", dataType = "String") })
	public ResultPojo getCheckDeviceInfo(
			@RequestParam(defaultValue = "",value="DevId",required=false) String DevId,
			HttpServletRequest request) {
		return checkDeviceInfoConsumeService.getCheckDeviceInfo(DevId);
	}
	
	/**
     * 获取巡检设备List
     * @param CheckRecordInfoId
     * @return
     */
	@GetMapping(value = { "/getCheckDeviceInfoList" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=CheckDeviceInfoDto.class, code = 0, message = "")
    @ApiOperation("获取巡检设备List")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "DevId", value = "设备编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devName", value = "设备名称", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "ledType", value = "诱导屏类型编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devStatusCode", value = "设备状态编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "isPingConnect", value = "网络是否联通", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "checkResultCode", value = "巡检结果编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devAreaCode", value = "区域编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "isDelayData", value = "是否延迟", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "isHightPackage", value = "是否高丢包", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "isHightResponse", value = "是否高响应", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "isHaveData", value = "是否有实时数据", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devFactory", value = "设备厂家", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "searchFlag", value = "标签识别", paramType = "query", dataType = "String")})
	public ResultPojo getCheckDeviceInfoList(
			@RequestParam(defaultValue = "",value="DevId",required=false) String DevId,
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			@RequestParam(defaultValue = "",value="devName",required=false) String devName,
			@RequestParam(defaultValue = "",value="ledType",required=false) String ledType,
			@RequestParam(defaultValue = "",value="devStatusCode",required=false) String devStatusCode,
			@RequestParam(defaultValue = "",value="isPingConnect",required=false) String isPingConnect,
			@RequestParam(defaultValue = "",value="checkResultCode",required=false) String checkResultCode,
			@RequestParam(defaultValue = "",value="devAreaCode",required=false) String devAreaCode,
			@RequestParam(defaultValue = "",value="isDelayData",required=false) String isDelayData,
			@RequestParam(defaultValue = "",value="isHightPackage",required=false) String isHightPackage,
			@RequestParam(defaultValue = "",value="isHightResponse",required=false) String isHightResponse,
			@RequestParam(defaultValue = "",value="isHaveData",required=false) String isHaveData,
			@RequestParam(defaultValue = "",value="searchFlag",required=false) String searchFlag,
			@RequestParam(defaultValue = "",value="devFactory",required=false) String devFactory,
			HttpServletRequest request) {
		return checkDeviceInfoConsumeService.getCheckDeviceInfoList(DevId,devTypeCode,devName,ledType,devStatusCode,isPingConnect,checkResultCode,devAreaCode,isDelayData,isHightPackage,isHightResponse,isHaveData,devFactory,searchFlag);
	}

	/**
     * 获取巡检设备分页
     * @param CheckRecordInfoId
     * @return
     */
	@GetMapping(value = { "/getCheckDeviceInfoPage" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=CheckDeviceInfoDto.class, code = 0, message = "")
    @ApiOperation("获取巡检设备分页")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "DevId", value = "设备编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devName", value = "设备名称", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "ledType", value = "诱导屏类型编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devStatusCode", value = "设备状态编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "isPingConnect", value = "网络是否联通", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "checkResultCode", value = "巡检结果编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devAreaCode", value = "区域编号", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "isDelayData", value = "是否延迟", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "isHightPackage", value = "是否高丢包", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "isHightResponse", value = "是否高响应", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "isHaveData", value = "是否有实时数据", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devFactory", value = "设备厂家", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "searchFlag", value = "标签识别", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "beginLastPassTime", value = "最后上传开始时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "endLastPassTime", value = "最后上传结束时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "isPhotoSuccess", value = "照片是否上传成功", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "repStatusCode", value = "设备使用状态", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "project", value = "项目期数", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "company", value = "建设单位", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "picStatusFlag", value = "图片质量", paramType = "query", dataType = "String")})
	public ResultPojo getCheckDeviceInfoPage(
			@RequestParam(defaultValue = "",value="DevId",required=false) String DevId,
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			@RequestParam(defaultValue = "",value="devName",required=false) String devName,
			@RequestParam(defaultValue = "",value="ledType",required=false) String ledType,
			@RequestParam(defaultValue = "",value="devStatusCode",required=false) String devStatusCode,
			@RequestParam(defaultValue = "",value="isPingConnect",required=false) String isPingConnect,
			@RequestParam(defaultValue = "",value="checkResultCode",required=false) String checkResultCode,
			@RequestParam(defaultValue = "",value="devAreaCode",required=false) String devAreaCode,
			@RequestParam(defaultValue = "",value="isDelayData",required=false) String isDelayData,
			@RequestParam(defaultValue = "",value="isHightPackage",required=false) String isHightPackage,
			@RequestParam(defaultValue = "",value="isHightResponse",required=false) String isHightResponse,
			@RequestParam(defaultValue = "",value="isHaveData",required=false) String isHaveData,
			@RequestParam(defaultValue = "",value="devFactory",required=false) String devFactory,
			@RequestParam(defaultValue = "",value="searchFlag",required=false) String searchFlag,
			@RequestParam(defaultValue = "",value="beginLastPassTime",required=false) String beginLastPassTime,
			@RequestParam(defaultValue = "",value="endLastPassTime",required=false) String endLastPassTime,
			@RequestParam(defaultValue = "",value="isPhotoSuccess",required=false) String isPhotoSuccess,
			@RequestParam(defaultValue = "",value="repStatusCode",required=false) String repStatusCode,
			@RequestParam(defaultValue = "",value="project",required=false) String project,
			@RequestParam(defaultValue = "",value="company",required=false) String company,
			@RequestParam(defaultValue = "",value="picStatusFlag",required=false) String picStatusFlag,
			Page page,
			HttpServletRequest request) {
		return checkDeviceInfoConsumeService.getCheckDeviceInfoPage(DevId,devTypeCode,devName,ledType,devStatusCode,isPingConnect,checkResultCode,devAreaCode,isDelayData,isHightPackage,isHightResponse,isHaveData,devFactory,searchFlag,beginLastPassTime,endLastPassTime,isPhotoSuccess,repStatusCode,project,company,picStatusFlag,page);
	}
	
	/**
     * 获取巡检数量
     * @param CheckRecordInfoId
     * @return
     */
	@GetMapping(value = { "/getCheckCount" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=CheckDeviceInfoDto.class, code = 0, message = "")
    @ApiOperation("获取巡检数量")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "beginTime", value = "开始时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型", paramType = "query", dataType = "String")})
	public ResultPojo getCheckCount(
			@RequestParam(defaultValue = "",value="beginTime",required=false) String beginTime,
			@RequestParam(defaultValue = "",value="endTime",required=false) String endTime,
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return checkDeviceInfoConsumeService.getCheckCount(beginTime, endTime,devTypeCode);
	}
	
	/**
     * 手动刷新巡检状态
     * @param CheckRecordInfoId
     * @return
     */
	@GetMapping(value = { "/reFreshCheckResult" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response=CheckDeviceInfoDto.class, code = 0, message = "")
    @ApiOperation("手动刷新巡检状态")
	@ApiImplicitParams({
    	@ApiImplicitParam(name = "devTypeCode", value = "设备类型", paramType = "query", dataType = "String")})
	public ResultPojo reFreshCheckResult(
			@RequestParam(defaultValue = "",value="devTypeCode",required=false) String devTypeCode,
			HttpServletRequest request) {
		return checkDeviceInfoConsumeService.reFreshCheckResult(devTypeCode);
	}
}
